package qf.module.mybatis.controller;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import qf.common.core.web.vo.AjaxResult;
import qf.module.mybatis.entity.ApiReqInfo;
import qf.module.mybatis.service.ApiReqInfoService;

import javax.annotation.Resource;

@RestController
@RequestMapping("mybatis/api")
@RefreshScope
public class MyBathisController {

    @Resource
    private ApiReqInfoService service;

    @RequestMapping("/v1/test")
    public AjaxResult myBatisTest() {
        System.out.println("qf-module-mybatis进来了！！！");
        return AjaxResult.success(service.findAll());
    }

    @RequestMapping(value = "/v2/test",method = RequestMethod.POST)
    public AjaxResult myBatisTest2(@RequestBody ApiReqInfo apiReqInfo) {
        System.out.println("myBatisTest2进来了！！！" + apiReqInfo.toString());
        return AjaxResult.success(service.save(apiReqInfo));
    }
}
